NumericRange
Represents a numeric range for supporting generic math operations.
Implementiert: IRange<T>, IRange, ICloneable
Konstruktoren
public NumericRange(TNumber min, TNumber max)
numericRange = NumericRange(min, max)
Initializes a new instance of the NumericRange struct.
- min
- The lower bound of the range (inclusive).
- max
- The upper bound of the range (inclusive).
Eigenschaften
public TNumber Length { get; }
value = numericRange.Length
Gets the range length computed as Max minus Min.
public TNumber Max { get; }
value = numericRange.Max
Gets the upper bound of the range (inclusive).
public TNumber Min { get; }
value = numericRange.Min
Gets the lower bound of the range (inclusive).
Methoden
public bool Contains(TNumber value)
result = numericRange.Contains(value)
Determines whether the specified value is contained in the current range (inclusive).
- value
- The value to test.
Rückgabe: true if lies in [Min, Max]; otherwise false.
public bool Contains(NumericRange<TNumber> other)
result = numericRange.Contains(other)
Determines whether the specified range is completely contained in the current range.
- other
- The range to test.
Rückgabe: true if is inside this range; otherwise false.
public NumericRange<TNumber>? Intersect(NumericRange<TNumber> other)
result = numericRange.Intersect(other)
Computes the intersection between the current range and .
- other
- The range to intersect with.
Rückgabe: A new NumericRange describing the overlap, or null when the ranges do not intersect.
public NumericRange<TNumber> SubRange(TNumber min, TNumber max)
result = numericRange.SubRange(min, max)
Creates a sub-range from the current range with the specified bounds.
- min
- The minimum bound of the sub-range.
- max
- The maximum bound of the sub-range.
Rückgabe: The sub-range within the current range.
public override string ToString()
result = numericRange.ToString()
Returns a string that represents the current range using the format "{Min: X Max: Y}".
Rückgabe: A string representation of the range.